;;; init-site-lisp.el --- Configuration for site-lisp directory -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(defvar ctrlwei-emacs-site-lisp-directory
  (expand-file-name "site-lisp/" user-emacs-directory)
  "Emacs third part Lisp packages.")

(defvar ctrlwei-emacs-site-lisp-loaddefs
  (expand-file-name "autoloads/site-lisp-loaddefs.el"
                    ctrlwei-emacs-site-lisp-directory)
  "The autoload file of site-lisp directory.")

;; Add packages obtained from Github or EmacsWiki to `load-path'
(nconc load-path (ctrlwei/list-dirs ctrlwei-emacs-site-lisp-directory))

(defun update-all-autoloads-in-site-lisp ()
  "Generate file autoload under site-lisp and put them in a file."
  (interactive)
  (loaddefs-generate (ctrlwei/list-dirs ctrlwei-emacs-site-lisp-directory)
                     ctrlwei-emacs-site-lisp-loaddefs)
  (load ctrlwei-emacs-site-lisp-loaddefs nil t))

(if (file-exists-p ctrlwei-emacs-site-lisp-loaddefs)
    (load ctrlwei-emacs-site-lisp-loaddefs nil t)
  (update-all-autoloads-in-site-lisp))

(provide 'init-site-lisp)
;;; init-site-lisp.el ends here
